package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.manger.activity.flowercard.FlowerCardsConfig;
import com.yanqu.road.server.manger.activity.flowercard.FlowerCardsMgr;

import java.util.ArrayList;
import java.util.List;

public class FlowerCardRecycleStrategy extends  AbstractItemRecycleStrategy{


    @Override
    public void markNeedRecycleItem() {
        ActivityInfo activityInfo = FlowerCardsMgr.getActivityInfo();
        FlowerCardsConfig cardsConfig = FlowerCardsMgr.getConfig();
        if (activityInfo != null &&  cardsConfig!= null) {
            long recycleTime = activityInfo.getEndShowTime() * 1000L + 600 * 1000;
            List<String> paramList = new ArrayList<>();
            paramList.add(String.valueOf(cardsConfig.getEnergyItemId()));
            paramList.add(String.valueOf(0));
            paramList.add("1");
            paramList.add(activityInfo.getActivityName());
            ActivityItemRecycleMgr.addRecycleItemData(cardsConfig.getEnergyItemId(), activityType, 1, recycleTime, paramList);
        }
    }

    @Override
    protected void initActivityType() {
        this.activityType = eActivityType.FlowerCards.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        int itemId = data.getItemId();
        UserBagItem bagItem = getUserBagItem(userId, itemId);
        removeItem(bagItem);
    }

    @Override
    public boolean isActivityRunning() {
        return true;
    }
}
